﻿using System;
using Data.implement;

namespace Data
{
    class IndexVisitingInfoRepositery : DataAccessBase<LYWebsiteSEntities1>, IIndexVisitingInfoRepositery
    {
        private static readonly log4net.ILog log =
            log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        public bool Record(string IP)
        {
            log.InfoFormat("IndexVisitingInfoRepositery.Record({0})", IP);
            IndexVistingInfo entity = new IndexVistingInfo()
            {
                IPAddress = IP, Date = DateTime.Now
            };
            InsertRecord(entity);
            return true;
        }

        public bool DeleteRecord(IndexVistingInfo entity)
        {
            log.InfoFormat("IndexVisitingInfoRepositery.Record({0})", entity.IPAddress);
            var result = GetRecordByProperty<IndexVistingInfo>(d => d.IPAddress == entity.IPAddress);
            return DeleteRecord(result);
        }
    }
}